# Maintainer: Daniel Sabogal <dsabogalcc@gmail.com>
pkgname=openmpi
pkgver=4.1.2
pkgrel=0
pkgdesc="Message passing library for high-performance computing"
url="https://www.open-mpi.org/"
# disable ppc64le until opal_fifo test can be fixed
arch="all"
license="custom" # BSD-based custom license
makedepends="perl gfortran hwloc-dev libevent-dev libgomp"
subpackages="$pkgname-dev:_dev $pkgname-doc"
source="https://www.open-mpi.org/software/ompi/v${pkgver%.*}/downloads/openmpi-$pkgver.tar.bz2"

build() {
	local disable_atomics=""
	case "$CARCH" in
		ppc64le) disable_atomics="--disable-builtin-atomics";;
	esac

	./configure \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--sysconfdir=/etc/$pkgname \
		--enable-ipv6 \
		--with-threads=posix \
		--with-hwloc=/usr \
		$disable_atomics
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

_dev() {
	default_dev

	local bins="mpiCC mpic++ mpicc mpicxx mpif77 mpif90 mpifort
		ortecc opal_wrapper"

	local i; for i in $bins; do
		amove usr/bin/$i
	done
}

sha512sums="
1958f96434cddbe525b4511fcf8d0cf8bf1ff376e024466219bd3a2092900e318f45a4b1e1a8ef6b03e350f46a71777fc7db82a7df711f12bb9758150d209aad  openmpi-4.1.2.tar.bz2
"
